package com.yuanqiworld.vw.domain;

import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
import org.springframework.roo.addon.json.RooJson;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.security.core.GrantedAuthority;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.validation.constraints.NotNull;
import java.util.HashSet;
import java.util.Set;

@RooJavaBean
@RooToString
@RooJson
@RooJpaActiveRecord(table = "vw_role", finders = "findRoleInfoesByRoleName")
public class RoleInfo{
    @NotNull
    @Column(unique = true)
    private String roleName;

    private String roleLabel;

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name="vw_role_authority",
            joinColumns = {@JoinColumn(name = "role_id")},
            inverseJoinColumns = {@JoinColumn(name = "authority_id")})
    private Set<AuthorityInfo> authorities = new HashSet<AuthorityInfo>();


}
